#!/bin/bash

function installMysql2(){
	yum -y install make gcc-c++ cmake bison-devel  ncurses-devel
	
}

#centos7 mysql5.6
function installMysql4(){
    echo "====================安装 mysql5.6======================"
    mkdir /mysql
	yum -y remove mysql-libs*
	yum -y remove mariadb*
	yum install -y libaio
	yum install -y numactl
	yum install -y net-tools
	cd /mysql
	wget http://oksnab29j.bkt.clouddn.com/MySQL-5.6.38-1.el7.x86_64.rpm-bundle.tar
	tar xvf MySQL-5.6.38-1.el7.x86_64.rpm-bundle.tar
	rpm -ivh MySQL-server-5.6.38-1.el7.x86_64.rpm
	rpm -ivh MySQL-devel-5.6.38-1.el7.x86_64.rpm
	rpm -ivh MySQL-client-5.6.38-1.el7.x86_64.rpm
	cp /usr/share/mysql/my-default.cnf /etc/my.cnf
	/usr/bin/mysql_install_db
	service mysql start
	echo "================> cat /root/.mysql_secret to see the password for mysql root"
}

#centos7 mysql5.7
function installMysql3(){
	wget  https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
	rpm -ivh ./mysql57-community-release-el7-9.noarch.rpm
	yum install -y mysql-server 
}

function installCommand(){
    echo "====================安装 command======================"
	yum install -y man
	yum install -y wget
	yum install -y vim
	yum install -y gcc
}

function installMysql(){
	yum install -y mysql-server
}

function installJava(){
    echo "====================安装 java======================"
	mkdir /java
	cd /java
	local javaDownloadURL="https://repo.huaweicloud.com/java/jdk/8u172-b11/"
	wget -c $javaDownloadURL -O java.tar.gz
	tar -xf java.tar.gz
	mv jdk1.8.0_172 jdk
	local comment="# set Java environment"
	local javaHomePath="/java/jdk"
	local javaHome="JAVA_HOME=$javaHomePath"
	local path="PATH=$javaHomePath/bin:$PATH"
	local classPath="CLASSPATH=.:$javaHomePath/lib/dt.jar:$javaHomePath/lib/tools.jar"
	echo $comment >> /etc/profile
	echo $javaHome >> /etc/profile
	echo $path >> /etc/profile
	echo $classPath >> /etc/profile
	source /etc/profile
	cd /
}

function installTomcat(){
    echo "====================安装 tomcat======================"
	local tomcatDownload="http://oksnab29j.bkt.clouddn.com/tomcat_all.tar.gz"
	mkdir /java/tomcat
	cd /java/tomcat
	wget -c $tomcatDownload -O tomcat.tar.gz
	tar -xf tomcat.tar.gz
	#mv apache-tomcat-6.0.45 tomcat6
}

function installMaven(){
    echo "====================安装 maven======================"
	local downloadUrl="http://oksnab29j.bkt.clouddn.com/apache-maven-3.5.2-bin.tar.gz"
	mkdir /maven
	cd /maven
	wget -c $downloadUrl -O maven.tar.gz
	tar -xf maven.tar.gz
	mv apache-maven-3.5.2 maven
	echo "export MAVEN_HOME=/maven/maven" >> /etc/profile
	echo "export PATH=${PATH}:${MAVEN_HOME}/bin" >> /etc/profile
	source /etc/profile
}

function start(){
	#installCommand
	#installJava
	#installTomcat
	#installMysql
	installMaven
}

function test(){
	local comment="# set Java environment"
	local javaHomePath="/java/jdk"
	local javaHome="JAVA_HOME=$javaHomePath"
	local path="PATH=$javaHomePath/bin:$PATH"
	local classPath="CLASSPATH=.:$javaHomePath/lib/dt.jar:$javaHomePath/lib/tools.jar"
	echo $comment >> /etc/profile
	echo $javaHome >> /etc/profile
	echo $path >> /etc/profile
	echo $classPath >> /etc/profile
	source /etc/profile
}

start

